#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdio.h>
void Left(char* p, int time,int len)
{
	char temp[10000] = "0";
	strcpy(temp, p + time);
	strncat(temp, p, time);
	strcpy(p, temp);
}
int main()
{
	char arr[10000] = "0";
	int k = 0;
	gets(arr);
	scanf("%d", &k) != EOF;
	int len = strlen(arr);
	int time = k % len;
	char* p = arr;
	Left(p, time,len);
	printf("%s", p);
	return 0;
}